import sys
from PyQt5.QtCore import Qt,QRect
from PyQt5.QtWidgets import QMainWindow, QWidget, QApplication,QShortcut,QLabel,QHBoxLayout,QFrame,QVBoxLayout,QStackedLayout
from PyQt5 import QtWidgets, uic
from PyQt5.QtGui import QKeySequence,QImage, QPixmap, QIcon
from utils.camera_wideget import CameraWidget


class MainFrom(QMainWindow):
    camera_status=0 #0摄像头关闭，1摄像头开
    model_status=0  #0录制模式,1播放模式
    work_status=0   #0待工作,1工作中，2暂停

    def __init__(self):
        super().__init__()
        uic.loadUi("resources/main.xml",self)
        self.setWindowTitle("播放器")
        self.initShort()

        self.cameraControl=CameraWidget()
        self.mainLayout=QStackedLayout()
        self.mainLayout.addWidget(self.cameraControl)

        self.mainWidget.setGeometry(self.geometry())
        self.mainWidget.setLayout(self.mainLayout)
        self.mainWidget.lower()

    def resizeEvent(self, event):
        self.mainWidget.setGeometry(0,0,10,10)
        self.mainWidget.resize(self.size())

    def initShort(self):
        ##设置快捷键
        self.shortcut = QShortcut(QKeySequence("Esc"), self)
        self.shortcut.activated.connect(QApplication.quit)
